package com.linxz.video.module.lifebroadcast;
import com.linxz.framework.base.ActivityLifeCycleEvent;
import com.linxz.framework.base.module.BaseModel;
import com.linxz.framework.protocol.callback.HttpCallBack;
import com.linxz.framework.protocol.callback.ModelCallBack;
import com.linxz.video.pojo.LiveBroadCastListResp;
import com.linxz.video.pojo.LiveBroadCastWrapBean;
import com.linxz.video.protocol.VideoApiStore;
import java.util.List;
import io.reactivex.subjects.PublishSubject;
/**
 * @author Linxz
 * 创建日期：2020年06月24日 07:59
 * version：v4.5.4
 * 描述：
 */
public class LifeBroadCastModule extends BaseModel {

    private VideoApiStore mVideoApiStore;

    public LifeBroadCastModule(PublishSubject<ActivityLifeCycleEvent> lifecycleSubject) {
        super(lifecycleSubject);
        mVideoApiStore=getOutApiStore(VideoApiStore.class);
    }


    public void getLiveBroadCast(int page,final ModelCallBack<List<LiveBroadCastWrapBean>> modelCallBack) {
        toSubscribe(mVideoApiStore.getLiveBroadcastList(page,15), new HttpCallBack<LiveBroadCastListResp>() {
            @Override
            public void onErrors(String code, String msg) {
                modelCallBack.onErrors(code, msg);
            }

            @Override
            public void onResponse(LiveBroadCastListResp liveBroadCastListResp) {
                if (liveBroadCastListResp.isOk()) {
                    modelCallBack.onSuccess(liveBroadCastListResp.getData());
                } else {
                    modelCallBack.onErrors(liveBroadCastListResp.getStatus(), liveBroadCastListResp.getMsg());
                }
            }
        });
    }


}
